<?php 
	require('funkcije.php');
	require('validacija.php');
?>
<center>
<form id="com_settings_form" action="" method="post" enctype="multipart/form-data">
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="table-layout: fixed; background: #FFFFFF; padding-top:10px; padding-left:10px; padding-right:10px; ">
	<?php if($_REQUEST['item'] > 0): ?>
	<tr>
		<td class="admin_cell" valign="top"  width="150"></td>
		<td colspan="2">
			<table cellpadding="0" cellspacing="0" border="0">
				<tr>
					<td height="20" >
						<input type="hidden" name="action" value="update">
						<input type="submit" value="Save" style="padding-left:20px; padding-right:10px;  background-image: url('../images/system/save.gif'); border:1px solid #DDDDDD; height:20px;" class="buttons">
						<button name="delete_menu" value="<?php echo $item['id']; ?>" style="padding-left:20px; padding-right:10px;  background-image: url('../images/system/delete.gif'); border:1px solid #DDDDDD;" class="buttons">Delete Menu</button>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<?php endif;?>
	<tr>
		<td class="admin_cell"   width="150">Selected Content:</td>
		<td class="admin_cell">
			<select name="content_type" onChange="document.location.href='?item='+this.value" style="width:300">
				<option value="0" selected>None / New</option>
				<?php 
					$result = mysql_query("SELECT * FROM ".DB_PERFIX."template_images;");
					while($row = mysql_fetch_array($result))
					{
						if ($row['id'] == $_REQUEST['item'])
						{
							echo '<option value="'.$row['id'].'" selected>'.$row['name'].'</option>';
						}
						else
						{
							echo '<option value="'.$row['id'].'">'.$row['name'].'</option>';
						}
					}
				?>
			</select>
		</td>
		<td class="admin_cell_stat" width="150"><?php echo $cTypeStatus; ?></td>
	</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="table-layout: fixed; background: #FFFFFF; padding-left:10px; padding-right:10px; margin:0px; ">
	<tr>
		<td class="admin_cell"  width="150">Name:</td>
		<td class="admin_cell" width="350">
			<input name="name" type="text" value="<?php echo $item['name']; ?>" style="width:300">
		</td>
		<td class="admin_cell_stat"><?php echo $cNameStatus; ?></td>
	</tr>
	<tr>
		<td class="admin_cell">Type:</td>
		<td class="admin_cell">
			<select name="menu_type"  style="width:300px;" <?php if($_REQUEST['item'] > 0): ?> onChange="document.location.href='?item=<?php echo $item['id']; ?>&type='+this.value" <?php endif; ?>>
				<option value="0" <?php if ($item['type'] == 0){echo 'selected'; }?>>Plain Image</option>
				<option value="1" <?php if ($item['type'] == 1){echo 'selected'; }?>>Image Local Link</option>
				<option value="2" <?php if ($item['type'] == 2){echo 'selected'; }?>>Image Remote Link</option>
			</select>
		</td>
		<td class="admin_cell_stat"></td>
	</tr>
	<?php if($_REQUEST['item'] < 1): ?>
	<tr>
		<td></td>
		<td style="padding-top:10px; padding-bottom:10px;">
			<input type="submit" value="Add new" class="buttons" style="padding-left:20px; padding-right:10px;  background-image: url('../images/system/new.gif'); border:1px solid #DDDDDD;" />
			<input type="hidden" name="action" value="new_item">
		</td>
		<td></td>
	</tr>
	<?php  else: ?>
	<tr>
		<td class="admin_cell">Active:</td>
		<td class="admin_cell">
			<a href="?item=<?php echo $item['id']; ?>&active=1"><img border="0" src="images/system/yes.png"></a>(Activate)&nbsp;&nbsp;
			<a href="?item=<?php echo $item['id']; ?>&active=0"><img border="0" src="images/system/no.png"></a>(Deactivate)
		</td>
		<td class="admin_cell_stat" align="left"><?php if ($item['active'] == 1){echo '<img border="0" src="images/system/yes.png"> Activated '; }else{echo '<img border="0" src="images/system/no.png"> Deactivated ';} ?></td>
	</tr>
	<?php if (($item['type'] == 0) || ($item['type'] == 1) || ($item['type'] == 2)):?>
	<tr>
		<td class="admin_cell">Image:</td>
		<td class="admin_cell">
			<input name="image" type="file" style="width:300px;" />
		</td>
		<td class="admin_cell_stat">
			<?php echo $error; ?>
			<?php 
				if($item['image'] != "")
				{
					$size = getimagesize(HTML_IMAGE_URL.$item['image']); 
					$fp = fopen(HTML_IMAGE_URL.$item['image'], "rb");
					if ($size && $fp) 
					{
						echo $size[0]." x ";
						echo $size[1]." px ";
						//echo $size[2];
						//echo $size[3];
					}
				}
				echo $ImageStatus;
			?>
		</td>
	</tr>
	<?php endif; ?>
	<?php if (($item['type'] == 1) || ($item['type'] == 2)):?>
	<tr>
		<td class="admin_cell">URL:</td>
		<td class="admin_cell">
			<input name="url" type="text" value="<?php echo $item['url']; ?>" style="width:300">
		</td>
		<td class="admin_cell_stat"></td>
	</tr>
	<?php endif; ?>
	<tr>
		<td class="admin_cell">Style:</td>
		<td class="admin_cell">
			<input name="style" type="text" value="<?php echo $item['style']; ?>" style="width:300">
		</td>
		<td class="admin_cell_stat"></td>
	</tr>
	<?php endif; ?>
	<?php if ($item['id'] > 0):?>
	<tr>
		<td class="admin_cell">Image: </td>
		<td class="admin_cell" colspan="2">
			<table cellpadding="0" cellspacing="0" border="0">
				<tr>
					<td><a href="<?php echo $item['url']; ?>"><img alt="<?php echo $item['name']; ?>" src="<?php echo HTML_IMAGE_URL.$item['image']; ?>" border="0" /></a></td>
				</tr>
			</table>
		</td>
	</tr>
	<?php endif; ?>
</table>
</form>

</center>

